﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Things.Web.Components
{
    public partial class SaleList : System.Web.UI.UserControl
    {
        protected Things.BLL.GoodsOrders goBll = new BLL.GoodsOrders();

        public Guid GoodsPriceID
        {
            get
            {
                string temp = hfGoodsPriceID.Value;
                Guid guid = Guid.Empty;
                if (Guid.TryParse(temp, out guid) == false)
                {
                    guid = Guid.Empty;
                }
                return guid;
            }
            set
            {
                hfGoodsPriceID.Value = value.ToString();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        public void BindData()
        {
            DataSet ds = new DataSet();
            ds = goBll.GetList(GoodsPriceID, Things.Common.ConstantString.GoodsOrderSatus.交易成功.ToString());
            gridView.DataSource = ds;
            gridView.DataBind();
        }

        protected void gridView_OnRowCreated(object sender, GridViewRowEventArgs e)
        {

        }

        protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {

        }

        protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gridView.PageIndex = e.NewPageIndex;
            BindData();
        }

        protected string GetUserName(object obj)
        {
            string userAccount = obj != null ? obj.ToString() : string.Empty;
            Things.BLL.BuyerInfo biBLL = new BLL.BuyerInfo();
            string userName = biBLL.GetUserName(userAccount,11);
            if (string.IsNullOrEmpty(userName) == true)
            {
                userName = userAccount;
            }
            return userName;
        }
    }
}